package cn.hzw.supermarket.adapter;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import java.util.ArrayList;
import java.util.List;

import cn.hzw.supermarket.R;

public class GuidePagerAdapter extends PagerAdapter {
    private int[] titles = new int[]{
            R.drawable.ic_guide_one,R.drawable.ic_guide_two,R.drawable.ic_guide_three,R.drawable.ic_guide_four};
    private List<View> views = new ArrayList<>();

    public GuidePagerAdapter() {
        super();
    }

    public int getCount() {
        return views.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(views.get(position));
        return views.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(views.get(position));
    }

    public List<View> getViews(){
        return views;
    }

    public int[] getTitles() {
        return titles;
    }
}
